// 获取订单状态徽章类
function getOrderStatusBadgeClass(status) {
    switch (status) {
        case 'PENDING_PAYMENT': return 'badge-secondary';
        case 'PENDING_COLLECTION': return 'badge-info';
        case 'COLLECTED': return 'badge-primary';
        case 'TRANSPORTING': return 'badge-primary';
        case 'OUT_FOR_DELIVERY': return 'badge-warning';
        case 'DELIVERY_FAILED': return 'badge-danger';
        case 'SIGNED': return 'badge-success';
        case 'COMPLETED': return 'badge-success';
        case 'CANCELLED': return 'badge-danger';
        case 'REFUNDED': return 'badge-danger';
        default: return 'badge-secondary';
    }
}

// 格式化订单状态
function formatOrderStatus(status) {
    switch (status) {
        case 'PENDING_PAYMENT': return '待付款';
        case 'PENDING_COLLECTION': return '待揽收';
        case 'COLLECTED': return '已揽收';
        case 'TRANSPORTING': return '运输中';
        case 'OUT_FOR_DELIVERY': return '派送中';
        case 'DELIVERY_FAILED': return '派送失败';
        case 'SIGNED': return '已签收';
        case 'COMPLETED': return '已完成';
        case 'CANCELLED': return '已取消';
        case 'REFUNDED': return '已退款';
        default: return status;
    }
}

// 获取配送员状态徽章类
function getDeliveryPersonStatusBadgeClass(status) {
    switch (status) {
        case 'IDLE': return 'badge-success';
        case 'DELIVERING': return 'badge-primary';
        case 'BUSY': return 'badge-warning';
        case 'OFFLINE': return 'badge-secondary';
        default: return 'badge-secondary';
    }
}

// 格式化配送员状态
function formatDeliveryPersonStatus(status) {
    switch (status) {
        case 'IDLE': return '空闲';
        case 'DELIVERING': return '配送中';
        case 'BUSY': return '忙碌';
        case 'OFFLINE': return '离线';
        default: return status;
    }
}

// 格式化日期
function formatDate(dateString) {
    if (!dateString) return '未知';
    
    const date = new Date(dateString);
    return date.toLocaleString('zh-CN', {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
        hour: '2-digit',
        minute: '2-digit'
    });
}

// 导出函数
window.getOrderStatusBadgeClass = getOrderStatusBadgeClass;
window.formatOrderStatus = formatOrderStatus;
window.getDeliveryPersonStatusBadgeClass = getDeliveryPersonStatusBadgeClass;
window.formatDeliveryPersonStatus = formatDeliveryPersonStatus;
window.formatDate = formatDate;